home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2002 September / PCpro_2002_09.ISO / techtalk / automationsuite / 247setup.exe / {app} / example.java < prev    next >
Encoding:
Java Source  |  2002-07-11  |  3.2 KB  |  91 lines

  1. import com.sybase.dpb.*;
  2. import com.softtreetech.scheduler.*;
  3.  
  4. public class example {
  5.  
  6.     public static void main(String arg[]) {
  7.     
  8.         // 1. Define global variables for JDPB_Connection and jdpb_24x7 classes:
  9.         JDPB_Connection myConnection = null;
  10.         jdpb_24x7 myRemoteControl = null;
  11.         
  12.  
  13.  
  14.         // 2. Instantiate the JDPB_Connection class and establish a new connection by passing 
  15.         //    arguments to the JDPB_Connection connect method:
  16.         
  17.         Integer portNo = new Integer(1096);
  18.         String hostName = new String("LocalHost");
  19.         String userID = new String("scott");
  20.         String userPass = new String("tiger");
  21.         String serial = new String("00000-00000");
  22.         String connectString = new String("");
  23.         myConnection = new JDPB_Connection();
  24.  
  25.         try {
  26.             myConnection.connect(hostName, 
  27.                                  portNo.intValue(), userID, 
  28.                                  serial, connectString);
  29.         } catch(java.lang.Throwable e) {
  30.             System.out.println( "Exception: " + e.getMessage() );
  31.             return;
  32.         }  // end catch 
  33.         
  34.  
  35.  
  36.         // 3. Instantiate the 24x7 Remote Control proxy class, passing the JDPB_Connection instance to 
  37.         //    the constructor:
  38.         myRemoteControl = new jdpb_24x7(myConnection);
  39.  
  40.  
  41.  
  42.         // 4. Call user 24x7 Remote Control functions from the Java application:
  43.         try {
  44.             // Open new session
  45.             String terminal = new String("");
  46.             Boolean htmlFormat = new Boolean(true);
  47.  
  48.             Integer ReturnValue = 
  49.                 myRemoteControl.opensession( terminal, userID, userPass, serial );
  50.  
  51.             if (ReturnValue.intValue() == 1) {
  52.                 // Ok. Connection opened, session started successfully,
  53.                 // now we can do the scheduling things...
  54.         
  55.                 // Change start time for job #12 to 6:00 AM
  56.                 ReturnValue =  myRemoteControl.setjobproperty( "12", "START_TIME", "6:00" );
  57.             } // end if
  58.         
  59.             if (ReturnValue.intValue() == 1) {
  60.                 // Ok. Job #12 START_TIME property changed successfully,
  61.                 // now let's get the job list in HTML format
  62.         
  63.                 StringHolder jobList = new StringHolder("");
  64.                 ReturnValue =  myRemoteControl.getjoblist( jobList, htmlFormat );
  65.         
  66.                 if (ReturnValue.intValue() == 1) {
  67.                     // print the job list
  68.                     System.out.println( jobList.getValue() );
  69.                 } // end if
  70.             } // end if
  71.         
  72.             if (ReturnValue.intValue() < 0) {
  73.                 // Handle the error
  74.                 System.out.println(myRemoteControl.getLasterror());
  75.             } // end if
  76.  
  77.             // Close session
  78.             myRemoteControl.closesession( );
  79.         } //end try
  80.         
  81.         catch (com.sybase.dpb.RemoteException e) {
  82.            System.out.println( "RemoteException exception: " + e.getMessage() );
  83.         }  // end catch 
  84.         
  85.  
  86.  
  87.         // 5. Disconnect from the 24x7 Scheduler server:
  88.         myConnection.disconnect();
  89.  
  90.     }
  91. }